package prototype.shallow;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
class Video implements Cloneable {
    private String name;

    private Date createTime;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}

public class ShallowTest {
    public static void main(String[] args) throws CloneNotSupportedException {
        Date date = new Date();

        Video video = new Video("Alex", date);      //原型对象
        Video clone = (Video) video.clone();              //克隆对象，浅拷贝

        date.setTime(223423543);

        System.out.println("prototype" + clone + " : " + clone.hashCode());
        //prototypeVideo(name=Alex, createTime=Sat Jan 03 22:03:43 CST 1970) : 343990810
        System.out.println("clone" + video + " : " + video.hashCode());
        //cloneVideo(name=Alex, createTime=Sat Jan 03 22:03:43 CST 1970) : 343990810
    }
}